package com.bilifuture.statemachine.config;

import com.bilifuture.statemachine.machine.StateMachine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author bilifuture
 * @description: 状态机初始化入口
 * @date 2022-04-02
 */
@Configuration
public class StateMachineAutoConfiguration {
    
    @Autowired
    private StateMachineProperties stateMachineProperties;
    
    @Bean
    @ConditionalOnMissingBean(StateMachine.class)
    StateMachine stateMachine(){
        return new StateMachine(stateMachineProperties.getConfigLocation());
    }
    
}
